package mycode;

import java.lang.reflect.Method;

import org.netbeans.jemmy.ClassReference;
import org.netbeans.jemmy.operators.JButtonOperator;
import org.netbeans.jemmy.operators.JFrameOperator;
import org.netbeans.jemmy.operators.JTextFieldOperator;
//import org.netbeans.jemmy.operators.JTreeOperator;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.AfterSuite;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Test;

public class WengTest {

	private ClassReference application;
	@BeforeSuite
	public void setup() throws ClassNotFoundException {
		application = new ClassReference("com.weng.RawFrame");
	}
	
	@AfterSuite
	public void teardown() {
		///
	}
	
	@SuppressWarnings("unused")
	@BeforeMethod
	public void startApplication(Method method) throws Exception {
		application.startApplication();
	}
	@AfterMethod
	public void closeApplication(){
		//application.
		try {
			Thread.sleep(20000);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	//
	@Test
	public void test(){
		 JFrameOperator mainFrame = new JFrameOperator("weng's app");
		 
		 try {
				Thread.sleep(2000);
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		 
		 JTextFieldOperator jtfo0= new JTextFieldOperator(mainFrame,0);
		 jtfo0.setText("weng");
		 
		 try {
				Thread.sleep(2000);
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		 
		 JTextFieldOperator jtfo1= new JTextFieldOperator(mainFrame,1);
		 jtfo1.setText("123");
		 		 try {
				Thread.sleep(2000);
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		 JButtonOperator jbo=new JButtonOperator(mainFrame);
		 jbo.push();
		 

		 
//		 new JButtonOperator(mainFrame, "Reload insfdsf").push();
//		 JTreeOperator tree = new JTreeOperator(mainFrame);
//
//		 //click in the middle of the tree
//		 tree.clickMouse();
//		 JTextFieldOperator testField = new JTextFieldOperator(mainFrame);
//
//		 //type new value in the text field
//		 testField.clearText();
//		 try {
//			Thread.sleep(4000);
//		} catch (InterruptedException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}
//		 testField.typeText("3");
	}
}
